package com.starrtc.demo.imclient.ClientSender;

import com.starrtc.demo.imclient.client.Controller;
import com.starrtc.demo.imclient.clientBuilder.ChatMsgBuilder;
import com.starrtc.demo.imclient.iMcommon.bean.ChatMsg;
import com.starrtc.demo.imclient.iMcommon.bean.msg.ProtoMsg;

public class ChatSender extends BaseSender {

    public static ChatSender instance;

    public static ChatSender getInstance(){
        if(instance == null){
            instance = new ChatSender();
            return instance;
        }
        return instance;
    }

    private ChatSender(){

    }

    public void sendChatMsg(String touid,String content) {
        ChatMsg chatMsg = new ChatMsg(getUser());
        chatMsg.setContent(content);
        chatMsg.setMsgType(ChatMsg.MSGTYPE.TEXT);
        chatMsg.setTo(touid);
        chatMsg.setMsgId(System.currentTimeMillis());
        ProtoMsg.Message message =
                ChatMsgBuilder.buildChatMsg(chatMsg, getUser(), getSession());
        commandClient = Controller.getInstance();
        super.sendMsg(message);
    }

    @Override
    protected void sendSucced(ProtoMsg.Message message) {



//        Print.tcfo("单聊发送成功:"
//                + message.getMessageRequest().getContent()
//                + "->"
//                + message.getMessageRequest().getTo());
//        commandClient.notifyCommandThread();
    }

    @Override
    protected void sendException(ProtoMsg.Message message) {
//        Print.tcfo("单聊发送异常:"
//                + message.getMessageRequest().getContent()
//                + "->"
//                + message.getMessageRequest().getTo());
//        commandClient.notifyCommandThread();
    }

    @Override
    protected void sendfailed(ProtoMsg.Message message) {
//        Print.tcfo("单聊发送失败:"
//                + message.getMessageRequest().getContent()
//                + "->"
//                + message.getMessageRequest().getTo());
//        commandClient.notifyCommandThread();
    }
}
